package com.uhu.tag;

import com.uhu.dto.req.TagCategorySaveReqDTO;
import com.uhu.dto.req.TagCategoryUpdateReqDTO;
import com.uhu.dto.res.TagCategoryQueryResDTO;
import com.uhu.tag.service.ITagCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liujunjie
 * @description 标签大类管理接口
 * @create 2023-11-22 15:31
 **/
@Api(tags = "标签大类管理接口")
@RestController
@RequestMapping("api/tag/category")
public class TagCategoryController {

    @Autowired
    private ITagCategoryService ITagCategoryService;

    @ApiOperation("查询标签大类")
    @GetMapping("select")
    public List<TagCategoryQueryResDTO> queryTagCategorySelect() {
        List<TagCategoryQueryResDTO> result = ITagCategoryService.queryTagCategorySelect();
        return result;
    }

    @ApiOperation("新增标签大类")
    @PostMapping("save")
    public void saveTagCategory(@RequestBody @Validated TagCategorySaveReqDTO tagCategorySaveReqDTO) {
        ITagCategoryService.saveTagCategory(tagCategorySaveReqDTO);
    }

    @ApiOperation("修改标签大类名称")
    @PutMapping("update")
    public void updateTagCategory(@RequestBody @Validated TagCategoryUpdateReqDTO tagCategoryUpdateReqDTO) {
        ITagCategoryService.updateTagCategory(tagCategoryUpdateReqDTO);
    }

    @ApiOperation("标签大类排序")
    @PutMapping("sort")
    public void sortTagCategory(@RequestBody Long[] ids) {
        ITagCategoryService.sortTagCategory(ids);
    }

    @ApiOperation("标签大类删除")
    @DeleteMapping("delete/{tagCategoryId}")
    public void deleteTagCategory(@PathVariable("tagCategoryId") Long tagCategoryId) {
        ITagCategoryService.deleteTagCategory(tagCategoryId);
    }
}
